package com.example.myshop.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.myshop.domain.AddressDao;
import com.example.myshop.entity.Address;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.stereotype.Service;
import org.springframework.test.context.junit4.SpringRunner;

@SpringBootTest
@RunWith(SpringRunner.class)
@Service
public class addressservicetest {
    @Autowired
    private AddressService addressService;
    @Autowired
    private AddressDao addressDao;

    @Test
    public void test1(){
        QueryWrapper<Address>queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("uid",2);
        addressDao.selectCount(queryWrapper);
    }
    @Test
    public void test2(){
        //addressService.addNewAddress();
        //addressService.setDefault(,);
        Address address=new Address();
        address.setPhone("15701650000");
        address.setName("Jack");
        address.setCityCode("110105");
        address.setAreaCode("110100");
        address.setProvinceCode("110000");
        addressService.addNewAddress(2L,"admin",address);
    }

    @Test
    public void getByUid(){
        System.out.println(addressService.getByUid(2L));
    }


    @Test
    public void getByAid(){
        System.out.println(addressService.getByUid(3L));
    }

    @Test
    public void setDefault(){
        addressService.setDefault(5L,2L,"test");
    }

    @Test
    public void delete(){
        addressService.delete(5L,2L,"admin");
    }

    @Test
    public void updateInfoByAid(){
        Address address=new Address();
        address.setName("test0529");
        address.setTag("临时住所");
        address.setAddress("广场");
        address.setPhone("1234567891");
        addressService.updateInfoByAid(4L,"root",address);
    }

}
